 package CurtainDesign.utils;

 import java.io.PrintStream;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;

 public class CurtainChecker
 {
   public static String simpleRectRegex = "((1L((S|D)1L)*)?(1R((S|D)1R)*)?(T(1L((S|D)1L)*)?(1R((S|D)1R)*)?)*)|((1L(B1L)*)?(1R(B1R)*)?(T(1L(B1L)*)?(1R(B1R)*)?)*)";
   public static String byFoldRegex = "(((1L(B1L)+)?(1R(B1R)+)?)|((1L((S|D)1L)+)?(1R((S|D)1R)+)?))";

   public static final boolean isEmpty(String input)
   {
     boolean blankTag = false;
     if ((null == input) || (0 == input.trim().length()))
     {
       blankTag = true;
     }
     return blankTag;
   }

   public static final boolean isInteger(String input)
   {
     boolean integerTag = false;
     if ((null != input) || (0 != input.trim().length()))
     {
       Pattern numpattern = Pattern.compile("\\d*");
       Matcher matcher = numpattern.matcher(input);
       if (matcher.matches())
       {
         integerTag = true;
       }
     }
     return integerTag;
   }

   public static final boolean isNumber(String input)
   {
     boolean numberTag = false;
     if ((null != input) || (0 != input.trim().length()))
     {
       Pattern numpattern = Pattern.compile("\\d*(.\\d*)?");
       Matcher matcher = numpattern.matcher(input);
       if (matcher.matches())
       {
         numberTag = true;
       }
     }
     return numberTag;
   }

   public static boolean isVaildHingeInstall(String hingeInstall, String regex)
   {
     boolean isVaild = true;
     if (!isEmpty(hingeInstall))
     {
       hingeInstall = hingeInstall.trim().toUpperCase();
       Pattern pattern = Pattern.compile(regex);
       Matcher matcher = pattern.matcher(hingeInstall);
       isVaild = matcher.matches();
     }
     else
     {
       isVaild = false;
     }
     return isVaild;
   }

   public static boolean isVaildByFoldNum(String hingeInstall)
   {
     boolean isVaild = true;
     hingeInstall = hingeInstall.toUpperCase();
     hingeInstall = hingeInstall.replaceAll("L", "");
     hingeInstall = hingeInstall.replaceAll("R", "");
     hingeInstall = hingeInstall.replaceAll("S", "");
     hingeInstall = hingeInstall.replaceAll("D", "");
     hingeInstall = hingeInstall.replaceAll("B", "");
     String[] distsHingeInstall = hingeInstall.split("T");
     int i = 0; for (int j = distsHingeInstall.length; i < j; i++) {
       if (distsHingeInstall[i].length() % 2 != 0) {
         isVaild = false;
         break;
       }
     }
     return isVaild;
   }

   public static void main(String[] args)
   {
     System.out.println(isVaildByFoldNum("1LB1LB1L1RB1R"));
   }
 }

/* Location:           C:\Users\Administrator\Desktop\奥特百叶窗\Shutter DesignerV3.1\CurtainDesign.jar
 * Qualified Name:     CurtainDesign.utils.CurtainChecker
 * JD-Core Version:    0.6.0
 */